import * as Cesium from 'cesium'
import * as turf from '@turf/turf' 
import PolylineMaterialPropery from './material/polyline'
export class RectFlyLight{
    constructor(viewer) {
        this.bbox = [
            113.2691, 23.014,
            113.3691, 23.159
        ]
        // 创建300个随机点
        let points = turf.randomPoint(300,{
            bbox: this.bbox
        })
        let features = points.features
        features.forEach(item => {
            let point = item.geometry.coordinates
            // 根据点设置起始位置
            let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], 0)
            // 根据点设置结束位置
            let end =  Cesium.Cartesian3.fromDegrees(point[0], point[1], 200 + Math.random() * 3000)
            // 创建自定义线材质
            let polylineMaterialPropery = new PolylineMaterialPropery()
            // 创建线
            let flyLine = viewer.entities.add({
                polyline: {
                    positions: [start, end],
                    width: 2,
                    material: polylineMaterialPropery
                }
            })
        });
    }
}